/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelo;

import java.util.Calendar;
import java.sql.Date;
import java.util.GregorianCalendar;

/**
 *
 * @author SAW
 */
public class Fecha {

    /**
   * Restar un dia a la fecha
   * @param  sql.Date
   * @return sql.Date
   */
  public java.sql.Date diaMenos(java.sql.Date fch){
     Calendar cal = new GregorianCalendar();
     cal.setTimeInMillis(fch.getTime());
     cal.add(Calendar.DATE, - 1);
     return new Date(cal.getTimeInMillis());
   }

  /**
   * Restar un dia a la fecha
   * @param  util.Date
   * @return sql.Date
   */
  public java.sql.Date diaMenos(java.util.Date fch){
     Calendar cal = new GregorianCalendar();
     cal.setTimeInMillis(fch.getTime());
     cal.add(Calendar.DATE, - 1);
     return new Date(cal.getTimeInMillis());
   }

   /**
   * Suma un dia a la fecha
   * @param  sql.Date
   * @return sql.Date
   */
  public java.sql.Date diaMas(java.sql.Date fch){
     Calendar cal = new GregorianCalendar();
     cal.setTimeInMillis(fch.getTime());
     cal.add(Calendar.DATE, + 1);
     return new Date(cal.getTimeInMillis());
   }

  /**
   * Suma un dia a la fecha
   * @param  util.Date
   * @return sql.Date
   */
  public java.sql.Date diaMas(java.util.Date fch){
     Calendar cal = new GregorianCalendar();
     cal.setTimeInMillis(fch.getTime());
     cal.add(Calendar.DATE, + 1);
     return new Date(cal.getTimeInMillis());
   }

  public Date calendarToDate(Calendar fecha){
      java.sql.Date javaSqlDate = new java.sql.Date(fecha.getTime().getTime());
      return javaSqlDate;
  }

}


